load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("fbcode_entropy_wardens_folly")

cpp_library(
    name = "ssl_session_cache_data",
    srcs = ["SSLSessionCacheData.cpp"],
    headers = ["SSLSessionCacheData.h"],
    exported_deps = [
        "//folly:fbstring",
        "//folly/json:dynamic",
        "//folly/ssl:openssl_ptr_types",
    ],
)

cpp_library(
    name = "ssl_session_cache_utils",
    srcs = ["SSLSessionCacheUtils.cpp"],
    headers = ["SSLSessionCacheUtils.h"],
    preprocessor_flags = [
        "-DWANGLE_HAVE_SSL_SESSION_DUP",
    ],
    deps = [
        "//folly/io:iobuf",
        "//wangle/ssl:ssl_util",
    ],
    exported_deps = [
        ":ssl_session_cache_data",
        "//folly:fbstring",
        "//folly:optional",
    ],
    exported_external_deps = [
        ("openssl", None, "ssl"),
    ],
)

cpp_library(
    name = "ssl_session_callbacks",
    srcs = ["SSLSessionCallbacks.cpp"],
    headers = ["SSLSessionCallbacks.h"],
    exported_deps = [
        ":ssl_session_cache_utils",
        "//folly/io/async:async_ssl_socket",
        "//folly/io/async:ssl_context",
        "//folly/ssl:openssl_ptr_types",
        "//wangle/ssl:ssl_util",
    ],
    exported_external_deps = [
        ("openssl", None, "ssl"),
    ],
)

cpp_library(
    name = "ssl_session_persistent_cache",
    headers = [
        "SSLSessionPersistentCache.h",
        "SSLSessionPersistentCache-inl.h",
    ],
    exported_deps = [
        ":ssl_session_cache_data",
        ":ssl_session_cache_utils",
        ":ssl_session_callbacks",
        "//folly:executor",
        "//folly:memory",
        "//folly/io:iobuf",
        "//folly/portability:openssl",
        "//folly/ssl:openssl_ptr_types",
        "//wangle/client/persistence:file",
        "//wangle/client/persistence:persistent_cache",
        "//wangle/client/persistence:persistent_cache_common",
    ],
    exported_external_deps = [
        ("openssl", None, "ssl"),
    ],
)

cpp_library(
    name = "threadsafe_cache",
    srcs = ["ThreadSafeSSLSessionCache.cpp"],
    headers = ["ThreadSafeSSLSessionCache.h"],
    exported_deps = [
        ":ssl_session_callbacks",
        "//folly:shared_mutex",
        "//folly/ssl:openssl_ptr_types",
    ],
)
